import 'package:wu_you/data/api/api.dart';
import 'package:wu_you/http/http.dart';
import 'package:wu_you/model/mall/purchase_model.dart';

class PurchaseRepository{
  factory PurchaseRepository() => _getInstance();

  static PurchaseRepository _instance;

  PurchaseRepository._internal();

  static PurchaseRepository _getInstance() {
    if (_instance == null) {
      _instance = PurchaseRepository._internal();
    }
    return _instance;
  }

  ///采购信息
  Future<PurchaseInfo> getPurchaseInfo() async {
    dynamic mapResult = await Http().post(Api.purchaseInfo);
    PurchaseInfo pi = PurchaseInfo.fromJson(mapResult);
    return pi;
  }

  ///商品购买
  static Future<dynamic> purChaseBuy(String address_id,String sku_id,int order_number,String pay_password,String remark) async {
    Map<String,dynamic> data = {
      "address_id":address_id,
      "sku_id":sku_id,
      "order_number":order_number,
      "pay_password":pay_password,
      "remark":remark
    };
    dynamic mapResult = await Http().post(Api.purchaseBuy, data: data);
    return mapResult;
  }

  ///采购返现领取
  Future<dynamic> purchaseReceive() async {
    dynamic mapResult = await Http().post(Api.purchaseReceive,showExtraInfo: true);
    return mapResult;
  }
}